﻿Namespace ExcelGenericOperations
    Public Module ExcelGenericOperations
        Public Sub TerminateExcelProcess(ByVal Application As Microsoft.Office.Interop.Excel.Application)
            For Each Cartella As Microsoft.Office.Interop.Excel.Workbook In Application.Workbooks
                For Each Foglio As Microsoft.Office.Interop.Excel.Worksheet In Cartella.Worksheets
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(Foglio)
                Next
                System.Runtime.InteropServices.Marshal.ReleaseComObject(Cartella)
            Next
            System.Runtime.InteropServices.Marshal.ReleaseComObject(Application)
        End Sub
    End Module
End Namespace


